<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class="app-container">
    <el-form id="mvcfm">
      <el-row>
        <el-col :span="10" :xs="24">
          <el-select @change="list_s_province" v-model="s_search.CMIDprovince">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_province" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <el-select @change="list_s_city" v-model="s_search.CMIDcity">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_city" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select>
          <div class="form-unit">
            <span class="mvc-title-left"> 地图位置 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="24">
                <baidu-map style="width:100%;height: 500px;" @ready="getMap"></baidu-map>
              </el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="14" :xs="24"> 公司 <el-select v-model="s_search.CMID7">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in l_firm" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select> 人员 <el-select v-model="s_search.CMID8">
            <el-option label="－－无－－" value='' />
            <el-option v-for="dict in s_person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
          </el-select> 客户名称 <div class="el-select">
            <el-input v-model="s_search.client_name3" />
          </div>
          <el-button @click="getPage(1);" type='primary' size="mini"><i class='fa fa-search'></i>搜索</el-button>
          <el-button @click="gotoPage('/psi/supplychainmana/SupplierAdd?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加供应商</el-button>
          <div>
          </div>
          <div class="form-unit">
            <span class="mvc-title-left"> 供应商 </span>
          </div>
          <el-table :data="pageList" v-loading="loading">
            <el-table-column label="#" align="center" type='index'>
            </el-table-column>
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_client('&CMID='+scope.row.client_id+'')">删除</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/psi/sale/SupplierUp?CMID='+scope.row.client_id+''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/psi/sale/SupplierDet?CMID='+scope.row.client_id+''+vueparams+'')">查看明细</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="供应商条形码" prop="client_barcode">
            </el-table-column>
            <el-table-column label="名称" prop="client_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('/psi/sale/SupplierDet?CMID='+scope.row.client_id+''+vueparams+'')" type='primary'>{{scope.row.client_name}}</el-link>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="client_class">
            </el-table-column>
            <el-table-column label="网站地址" prop="client_net">
            </el-table-column>
            <el-table-column label="管理人" prop="pname">
            </el-table-column>
            <el-table-column label="部门" prop="allfirm">
            </el-table-column>
            <el-table-column label="录入时间" prop="client_entime">
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12" :xs="24">
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'CartogramSupplier',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams("&CMID3=1&CMID4=1&CMID5=3"),
        s_search: {
          CMID7: null,
          CMID8: null,
          client_name3: null,
        },
        message: [],
        s_province: [],
        s_city: [],
        l_firm: [],
        s_person: [],
        loading: true,
        pageList: [],
        pageSize: 10,
        total: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.getPage(1);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/cartogramSupplier?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
          this.mvc.loadMap(this.map, this.baidumap);
        })
      },
      getPage(page) {
        this.loading = true;
        this.s_search.pageNo = page.page || page;
        this.s_search.pageSize = page.limit || 10;
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/SupplierAction/message?' + this.vueparams,
          params: this.s_search
        }).then(data => {
          this.loading = false;
          this.pageList = data.rows;
          this.total = data.total;
        })
      },
      list_s_province(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMIDprovince=" + value);
        } else if (this.$route.fullPath.indexOf("CMIDprovince=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMIDprovince=" + value);
        } else {
          this.gotoPage("/redirect/psi/supplychainmana/CartogramSupplier?" + this.vueparams, {
            CMIDprovince: value
          });
        }
      },
      list_s_city(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMIDcity=" + value);
        } else if (this.$route.fullPath.indexOf("CMIDcity=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMIDcity=" + value);
        } else {
          this.gotoPage("/redirect/psi/supplychainmana/CartogramSupplier?" + this.vueparams, {
            CMIDcity: value
          });
        }
      },
      getMap({
        BMap,
        map
      }) {
        this.map = map;
      },
    },
  }
</script>
